//
// Created by xili on 2024/9/20 20:50.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

//字母异位词排序后相等
class Solution {
public:
    vector <vector<string>> groupAnagrams(vector <string> &strs) {
        unordered_map <string, vector<string>> ump;
        for (auto &it: strs) {
            auto t = it;
            sort(t.begin(), t.end());
            ump[t].push_back(it);
        }
        vector <vector<string>> ans;
        for (auto &it: ump) {
            ans.push_back(it.second);
        }
        return ans;
    }
};